#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Geometry.h>
#include <Length.h>
#include <Condition.h>
#include <IsGtThan.h>
#include <IsLsThan.h>
#include <IsNotGtThan.h>
#include <IsNotLsThan.h>
#include <Precision.h>
#include <cmath>

USING_MOCKCPP_NS USING_TESTNGPP_NS

namespace
{
    Precision PRECISION_FLOOR(2, std::floor);
    Precision PRECISION_ROUND(2, round);
    IsGtThan IS_GREATER_THAN(0);
    IsNotGtThan IS_NOT_GREATER_THAN(100);
    IsLsThan IS_LESS_THAN(75);
    Checker LENGTH_CHECKER(&IS_GREATER_THAN, &IS_NOT_GREATER_THAN);
    Checker WIDTH_CHECKER(&IS_GREATER_THAN, &IS_LESS_THAN);

    const Length validLength(100.001, &PRECISION_FLOOR, &LENGTH_CHECKER);
    const Length validWidth(74.991, &PRECISION_FLOOR, &WIDTH_CHECKER);
    const Length invalidLength(100.001, &PRECISION_FLOOR, &LENGTH_CHECKER);
    const Length invalidWidth(75, &PRECISION_FLOOR, &WIDTH_CHECKER);


}

FIXTURE(Geometry)
{
    Geometry *geometry;
    SETUP()
    {
        geometry = getGeometry(validLength, validWidth);
    }
    TEARDOWN()
    {
        geometry = 0;
    }

    TEST(Valid Geometry getArea(100.001,74.991) should be 7499)
    {
        ASSERT_EQ(7499,geometry->getArea(validLength, validWidth));
    }

    TEST(Valid Geometry getPerimeter(100.001,74.991) should be 349.98)
    {
         ASSERT_EQ(349.98,geometry->getPerimeter(validLength, validWidth));
    }

    TEST(Valid Geometry isValid(100.001,74.991) should be true)
    {
        ASSERT_TRUE(geometry->isValid());
    }

};

FIXTURE(InvalidGeometry)
{
    Geometry *geometry;
    SETUP()
    {
        geometry = getGeometry(invalidLength, invalidWidth);
    }
    TEARDOWN()
    {
        geometry = 0;
    }

    TEST(inValid Geometry getArea(100.01,74.991) should be 0)
    {
        ASSERT_EQ(0, geometry->getArea(invalidLength, invalidWidth));
    }

    TEST(inValid Geometry getPerimeter(100.01,74.991) should be 0)
    {
         ASSERT_EQ(0,geometry->getPerimeter(invalidLength, invalidWidth));
    }

    TEST(inValid Geometry isValid(100.01,74.991) should be 0)
    {
        ASSERT_FALSE(geometry->isValid());
    }

};



